<template>
    <div class="booking-create-template">
        <el-button class="return" type="text" @click="jumpToDefault"><i class="fa fa-angle-left mr5"></i>返回</el-button>
        <h4 class="header">创建预约信息</h4>
        <div class="content">
            <div class="filter-section">
                <span class="fl title">预约基本信息</span>
                <span class="fr gray">注：带有*为必填项</span>
            </div>
            <div class="booking-form">
                <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px">
                    <el-form-item label="机构名称" prop="JGName">
                        <el-input v-model="ruleForm.JGName" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="预约联系人" prop="contact">
                        <el-input v-model="ruleForm.contact" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="预约时间" prop="bookingTime" class="simple-fl">
                        <el-date-picker type="datetime" v-model="ruleForm.bookingTime" size="mini"></el-date-picker>
                    </el-form-item>
                    <el-form-item label="预约人手机" prop="phone">
                        <el-input v-model="ruleForm.phone" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="预约状态" prop="bookingStatus">
                        <el-select v-model="ruleForm.bookingStatus" size="mini">
                            <el-option label="正常" value="1"></el-option>
                            <el-option label="异常" value="0"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="预约设置人" prop="bookingPerson">
                        <el-input v-model="ruleForm.bookingPerson" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="操作人" prop="operator">
                        <el-input v-model="ruleForm.operator" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="预约提醒" prop="bookingRemind">
                        <el-radio-group v-model="ruleForm.bookingRemind" size="mini">
                            <el-radio label="1">是</el-radio>
                            <el-radio label="0">否</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item label="预约目的" prop="bookingPurpose" class="form-textarea">
                        <el-input type="textarea" v-model="ruleForm.bookingPurpose" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="预约结果" prop="bookingResult" class="form-textarea">
                        <el-input type="textarea" v-model="ruleForm.bookingResult" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="submitForm('ruleForm')">确定</el-button>
                        <el-button @click="cancelForm()">取消</el-button>
                    </el-form-item>
                </el-form>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: "BookingCreate",
        data() {
            return {
                ruleForm: {
                    JGName: "",
                    contact: "",
                    bookingTime: "",
                    phone: "",
                    bookingPurpose: "",
                    bookingResult: "",
                    bookingStatus: "",
                    bookingPerson: "",
                    operator: "",
                    bookingRemind: ""
                },
                rules: {
                    JGName: [
                        {required: true, message: '请输入机构名称', trigger: 'blur'}
                    ],
                    contact: [
                        {required: true, message: '请输入预约联系人', trigger: 'blur'}
                    ],
                    bookingTime: [
                        {required: true, message: '请选择预约时间', trigger: 'change'},
                    ],
                    phone: [
                        {required: true, message: '请输入预约人手机', trigger: 'blur'}
                    ],
                    bookingStatus: [
                        {required: true, message: '请选择预约状态', trigger: 'change'},
                    ],
                    bookingPerson: [
                        {required: true, message: '请输入预约设置人', trigger: 'blur'}
                    ],
                    operator: [
                        {required: true, message: '请输入操作人', trigger: 'blur'}
                    ],
                }
            }
        },
        methods: {
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        console.log('submit!');
                        this.jumpToDefault();
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            cancelForm() {
                this.jumpToDefault();
            },
            jumpToDefault() {
                this.$parent.curPath = 'default';
            }
        }
    }
</script>

<style lang="scss">
    @import "src/common/common.style";
    .booking-create-template {
        background-color: #ffffff;
        width: 100%;
        height: 100%;
        position: relative;
        .return {
            position: absolute;
            top: 0;
            left: 15px;
            padding: 0;
        }
        .header {
            text-align: center;
        }
        .content {
            height: calc(100% - 60px);
            .filter-section {
                border-bottom: 1px solid #ddd;
                padding-bottom: 25px;
                margin: 0 10px;
                padding-left: 5px;
                padding-right: 5px;
                .title {
                    font-size: $font-mn;
                    font-weight: 600;
                }
                .gray {
                    color: gray;
                }
            }
            .booking-form {
                padding-top: 10px;
                height: calc(100% - 30px);
                @include ofy-a();
                .el-form {
                    margin: 0 50px;
                    .el-form-item:not(.form-textarea) {
                        margin-bottom: 15px;
                        display: inline-block;
                        width: 50%;
                        .el-form-item__content {
                            @include fl();
                            margin-left: 0 !important;
                        }
                        .el-input {
                            width: 300px;
                        }
                    }
                    .simple-fl {
                        @include fl();
                    }
                    .form-textarea {
                        clear: both;
                        .el-textarea, .el-input__inner {
                            width: 80%;
                            float: left;
                            .el-textarea__inner {
                                min-height: 100px !important;
                            }
                        }
                    }
                    .el-button {
                        width: 100px;
                        margin: 0 50px;
                    }
                }
            }
        }
    }
</style>